﻿using Abp.Application.Services.Dto;
using AutoMapper;
using Mt.Site.Core.Organizations.UserCache.Models;
using Mt.Site.Core.WorkFlows.Enum;
using Mt.Site.Core.WorkFlows.Process.Entities;
using System;
using System.ComponentModel.DataAnnotations;

namespace Mt.Site.Core.WorkFlows.Process.Models
{
    /// <summary>
    /// 用于催办时查找追责对象
    /// </summary>
    public interface IResponsibilityLink
    {
        Guid Id { get; }

        long UserId { get; }

        // null代表自己， GUID.Empty 代表不催办，Guid代表催办对象的任务id
        Guid? ResponsibilityId { get; }
    }

    [Abp.AutoMapper.AutoMap(typeof(WorkFlowProcess))]
    public class WorkFlowProcessDto : AuditedEntityDto<Guid> , IResponsibilityLink
    {
        /// <summary>
        /// 所属流程
        /// </summary>
        public Guid WorkFlowId { get; set; }

        /// <summary>
        /// 当前所处步骤
        /// </summary>
        public Guid NodeId { get; set; }
        public string NodeName { get; set; }

        public long UserId { get; set; }

        public string UserName { get; set; }

        public string UserInfoDtoJson { get; set; }

        public Guid PaperId { get; set; }

        public ActionState State { get; set; }

        /// <summary>
        /// 已阅
        /// </summary>
        public bool HasMarked { get; set; }

        public DateTime? MarkedTime { get; set; }

        [StringLength(WorkFlowProcess.MaxReplyLength)]
        public string Reply { get; set; }

        //最后一次回应时间
        public DateTime? ReplyTime { get; set; }


        /// <summary>
        /// 办理时间
        /// </summary>
        public DateTime? FinishedTime { get; set; }


        public Guid? TrunkId { get; set; }

        /// <summary>
        /// 上一个操作者对应的数据id（创建这条任务的上一个任务操作者）
        /// </summary>
        public Guid? PreStepId { get; set; }

        /// <summary>
        /// 前一个操作者的数据ID （修改这条任务数据状态的上一个任务操作者）
        /// </summary>
        public Guid? PreOperatorId { get; set; }


        public ActionScheme ActionScheme { get; set; }

        public DateTime StartTime { get; set; }

        public bool IsDefaultMsg { get; set; }


        [IgnoreMap]
        public UserInfoDto UserInfo { get; set; }

        public string Code { get; set; }

        public int StepCode { get; set; }

        public MoveMode MovePattern { get; set; }

        public OperationType OperationType { get; set; }

        public bool HasRead { get; set; }

        public string CustomData { get; set; }

        public string WaitingList { get; set; }

        public Guid? ResponsibilityId { get; set; }

        public Guid? FinishedByTheWay { get; set; }

        public bool Parallel { get; set; }

        // 传阅任务可能要求跨步骤完成
        public Guid? EndNodeId { get; set; }

        /// <summary>
        /// 用于做一些自定义标记，为后续的操作传递一些判别条件等
        /// </summary>
        public string Signal { get; set; }

        /// <summary>
        /// 用于做一些自定义标记，为后续的操作传递一些判别条件等 ，做进一步的判别
        /// </summary>
        public string Signal2 { get; set; }

        public bool IsHiddenInTable { get; set; }

        public WorkFlowOpSeverity Severity { get; set; }

        public string FormDataCache { get; set; }

        public bool CanEditForm { get; set; } 
    }
}
